package com.magicode.screen.api.remote;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URLEncoder;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.loopj.android.http.AsyncHttpClient;
import com.magicode.screen.AppConfig;
import com.magicode.screen.AppContext;
import com.magicode.screen.api.ApiHttpClient;
import com.magicode.screen.bean.User;
import com.magicode.screen.util.CyptoUtils;

import org.apache.http.Header;
import org.apache.http.client.CookieStore;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.cookie.Cookie;
import org.apache.http.protocol.HttpContext;
import org.kymjs.kjframe.http.HttpConfig;

import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class MgcApi {

    /**
     * 登陆
     *
     * @param username
     * @param password
     * @param handler
     */
    public static void login(String username, String password,
                             AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("loginName", username);
        params.put("password", password);
//        params.put("keep_login", 1);
        String loginurl = "mobile/main/user/login";
        ApiHttpClient.post(loginurl, params, handler);
    }
    /**
     * 默认登陆
     *
     * @param username
     * @param password
     * @param handler
     */
    public static void defaultLogin(String username, String password,
                             AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("loginName", username);
        params.put("password", password);
//        params.put("keep_login", 1);
        String loginurl = "mobile/main/user/defaultLogin?para1=abcd&para2=abcd2";
        ApiHttpClient.post(loginurl, params, handler);
    }

    /**
     * getNewsShare
     *向服务器发请求获取分享的基本参数
     * @param newsId
     * @param handler
     */
    public static void getNewsShare(String newsId, AsyncHttpResponseHandler handler,String type) {
        RequestParams params = new RequestParams();
        params.put("entityId", newsId);
        params.put("entityType", type);
        String url = "portal/common/share";
        ApiHttpClient.post(url, params, handler);
    }

    /**
     *向服务器发请求获取服务器最新版本号
     * @param handler
     */
    public static void getVersion( AsyncHttpResponseHandler handler,String version) {
        RequestParams params = new RequestParams();
        params.put("currentVersion", version);
        String url = "portal/common/checkNewVersion";
        ApiHttpClient.post(url, params, handler);

    }
    /**
     * 根据本地存储用户信息,默认登陆
     */
    public static void defaultLogin() {
        if(null!=AppContext.getInstance()) {
            String userId = AppContext.getInstance().getLoginUid();
            String loginName = AppContext.getInstance().getProperty("user.loginName");
            String password = CyptoUtils.decode("MagicodeApplication", AppContext.getInstance().getProperty("user.password"));
            if (null != userId && !"".equals(userId) && null != loginName && !"".equals(loginName) &&
                    null != password && !"".equals(password)) {
                RequestParams params = new RequestParams();
                params.put("loginName", loginName);
                params.put("password", password);
//        params.put("keep_login", 1);
                String loginurl = "mobile/main/user/defaultLogin";
                ApiHttpClient.post(loginurl, params, mDefaultLoginHandler);
            }
        }

    }
    /**
     * 第三方登陆
     *
     * @param handler
     */
    public static void outerLogin(String userId,  String nickName , String sex ,
                                  String province, String city, String unionid,String headimgurl,
                             AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("userId", userId);
        params.put("nickname", nickName);
        params.put("sex", sex);
        params.put("province", province);
        params.put("city", city);
        params.put("unionid", unionid);
        params.put("headimgurl", headimgurl);
        params.put("type", "wechat");
        String loginurl = "/portal/user/outerLogin";
        ApiHttpClient.post(loginurl, params, handler);
    }
    /**
     * 支付，提交订单
     * 支持微信、支付宝
     * @param handler
     */
    public static void outerpay(String userToken,  String payType , Integer amount ,AsyncHttpResponseHandler handler, String... productId) {
        RequestParams params = new RequestParams();
        params.put("userToken", userToken);
        params.put("amount", amount);
        params.put("payType", payType);

        if (productId.length != 0)
            params.put("productId", productId[0]);

        String loginurl = "portal/unionPay/topupand";
        ApiHttpClient.post(loginurl, params, handler);
    }

//    public static void outerpay(String userToken,  String payType , String productId , Integer productType ,AsyncHttpResponseHandler handler) {
//        RequestParams params = new RequestParams();
//        params.put("userToken", userToken);
//        params.put("productId", productId);
//        params.put("productType", productType);
//        params.put("payType", payType);
//
//
//        String loginurl = "portal/unionPay/raise";
//
//        ApiHttpClient.post(loginurl, params, handler);
//    }

    /**
     * 检查是否支付成功
     * @param outTradeId
     * @param userToken
     * @param handler
     */
    public static void payCheck(String outTradeId , String userToken , AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("userToken", userToken);
        params.put("outTradeId", outTradeId);
        String  loginurl = "portal/unionPay/check";
        ApiHttpClient.post(loginurl, params, handler);
    }
    /**
     *注册
     * @param username
     * @param password
     * @param loginName
     * @param email
     * @param mobile
     */
    public static void regist(String username, String password,String loginName ,String email , String mobile,
                             AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("loginName", loginName);
        params.put("password", password);
        params.put("email", email);
        if(username != null && username.trim() .length() > 0) {
            params.put("username", username);
        }
        if(mobile != null && mobile.trim() .length() > 0) {
            params.put("mobile", mobile);
        }
        String url = "/mobile/main/user/regist";
        ApiHttpClient.post(url, params, handler);
    }
    /**
     *
     * @param email
     */
    public static void forgetPassword(String email ,
                              AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("email", email);
        String url = "http://www.media-plus.cn/uf/send";
        ApiHttpClient.post(url, params, handler);
    }
    /**
     *
     * @param loginName
     * @param email
     * @param mobile
     */
    public static void registValidate(String loginName, String email,String mobile ,
                              AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        if(loginName != null && loginName.trim().length() > 0) {
            params.put("loginName", loginName);
        }
        if(email != null && email.trim().length() > 0) {
            params.put("email", email);
        }
        if(mobile != null && mobile.trim().length() > 0) {
            params.put("mobile", mobile);
        }
        String url = "/mobile/main/user/registervalid";
        ApiHttpClient.post(url, params, handler);
    }
    /**
     * 获取用户信息
     *
     * @param id
     * @param handler
     */
    public static void getUserDetail(String id, AsyncHttpResponseHandler handler) {
      //  RequestParams params = new RequestParams("id", id);
        RequestParams params = new RequestParams();
        ApiHttpClient.post("mobile/main/user/getUser/" + id, params, handler);
    }
    /**
     * 修改用户信息
     *
     * @param username
     * @param userId
     * @param handler
     */
    public static void updateUser(String userId,String loginName,String username,
                                  String mobile,String email,String companyName,String jobName,
                                  AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("id", userId);
        params.put("loginName", loginName);
        params.put("userName", username);
        params.put("mobile", mobile);
        params.put("email", email);
        params.put("currentCompanyName", companyName);
        params.put("jobName", jobName);
        String loginurl = "mobile/main/user/updateUser";
        ApiHttpClient.post(loginurl, params, handler);
    }

    /**
     * 获取新闻列表
     * 
     * @param mTabId
     *            类别 （1，2，3）
     * @param page
     *            第几页
     * @param handler
     */
    public static void getNewsList(int mTabId, int page,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mTabId", mTabId);
        params.put("pageIndex", page);
        params.put("pageSize", AppContext.PAGE_SIZE);
//        if (mTabId == NewsList.mTabId_WEEK) {
//            params.put("show", "week");
//        } else if (mTabId == NewsList.mTabId_MONTH) {
//            params.put("show", "month");
//        }
        ApiHttpClient.post("action/api/news_list", params, handler);
    }
    /**
     * 获取新闻列表
     * 
     * @param mTabId
     *            类别 （1，2，3）
     * @param page
     *            第几页
     * @param handler
     */
    public static void getNewsList(String mTabId, int page,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mTabId", mTabId);
        params.put("currentPage", page);
        params.put("pageSize", AppContext.PAGE_SIZE);
//        if (mTabId == NewsList.mTabId_WEEK) {
//            params.put("show", "week");
//        } else if (mTabId == NewsList.mTabId_MONTH) {
//            params.put("show", "month");
//        }
        ApiHttpClient.post("mobile/main/article/datalist", params, handler);
    }
    /**
     * 用户针对某个新闻，帖子，动弹，消息发表评论的接口，参数使用POST方式提交
     *
     * @param id
     *            被评论的某条新闻的id
     * @param uid
     *            当天登陆用户的UID
     * @param content
     *            发表的评论内容
     * @param handler
     */
    public static void commentCreate(String id,String entityName,String uid, String content, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("entityId", id);
        params.put("entityName", entityName);
        params.put("userId", uid);
     //   params.add("userId",AppContext.getInstance().getLoginUid());
        params.put("commentContent", content);
        ApiHttpClient.post("mobile/main/comments/create", params, handler);
    }

    /**
     * 获取评论列表
     *
     * @param id
     * @param handler
     */
    public static void getCommentdataList(String id,String entityName, int page, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("id", id);
        params.put("entityName", entityName);
        params.put("currentPage", page);
        params.put("pageSize", AppContext.PAGE_SIZE);
        ApiHttpClient.post("mobile/main/comments/datalist/"+id, params, handler);
    }
    /**
     * 获取评论列表
     *
     * @param id
     * @param mTabId
     *            1新闻 2帖子 3动弹 4动态
     * @param page
     * @param handler
     */
    public static void getCommentList(String id, String mTabId, int page,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mTabId", mTabId);
        params.put("id", id);
        params.put("pageIndex", page);
        params.put("pageSize", AppContext.PAGE_SIZE);
        ApiHttpClient.post("action/api/comment_list", params, handler);
    }

    public static void getBlogCommentList(int id, int page,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("id", id);
        params.put("pageIndex", page);
        params.put("pageSize", AppContext.PAGE_SIZE);
        ApiHttpClient.post("action/api/blogcomment_list", params, handler);
    }

    public static void getUserInformation(String uid, int hisuid, String hisname,
            int pageIndex, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("uid", uid);
        params.put("hisuid", hisuid);
        params.put("hisname", hisname);
        params.put("pageIndex", pageIndex);
        params.put("pageSize", AppContext.PAGE_SIZE);
        ApiHttpClient.post("action/api/user_information", params, handler);
    }

    @SuppressWarnings("deprecation")
    public static void getUserBlogList(int authoruid, final String authorname,
            final String uid, final int pageIndex, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("authoruid", authoruid);
        params.put("authorname", URLEncoder.encode(authorname));
        params.put("uid", uid);
        params.put("pageIndex", pageIndex);
        params.put("pageSize", AppContext.PAGE_SIZE);
        ApiHttpClient.post("action/api/userblog_list", params, handler);
    }

    public static void getMyInformation(String uid,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        ApiHttpClient.post("mobile/main/user/getUser/" + uid, params, handler);
    }
    public static void getMyInforTop(String uid,AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("userId", uid);
        ApiHttpClient.post("mobile/main/user/vipUserJson", params, handler);
    }

    /**
     * 获取新闻明细
     * 
     * @param id
     * @param handler
     */
    public static void getNewsDetail(String id, AsyncHttpResponseHandler handler, AsyncHttpResponseHandler normalHandler) {
        RequestParams params = new RequestParams("id", id);
        ApiHttpClient.post("mobile/main/article/sec/"+id, params, handler);
        addClick(id,"com.magicode.cms.entiy.base.News",  normalHandler);
    }
    /**
     * 用户针对某个新闻，帖子，动弹，消息发表评论的接口，参数使用POST方式提交
     * 
     * @param mTabId
     *            　　 1新闻　　2 帖子　　３　动弹　　４消息中心
     * @param id
     *            被评论的某条新闻，帖子，动弹或者某条消息的id
     * @param uid
     *            当天登陆用户的UID
     * @param content
     *            发表的评论内容
     * @param isPostToMyZone
     *            是否转发到我的空间，０不转发　　１转发到我的空间（注意该功能之对某条动弹进行评论是有效，其他情况下服务器借口可以忽略该参数）
     * @param handler
     */
    public static void publicComment(int mTabId, String id, String uid,
            String content, int isPostToMyZone, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mTabId", mTabId);
        params.put("id", id);
        params.put("uid", uid);
        params.put("content", content);
        params.put("isPostToMyZone", isPostToMyZone);
        ApiHttpClient.post("action/api/comment_pub", params, handler);
    }

    public static void replyComment(int id, int mTabId, int replyid,
            int authorid, String uid, String content,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mTabId", mTabId);
        params.put("id", id);
        params.put("uid", uid);
        params.put("content", content);
        params.put("replyid", replyid);
        params.put("authorid", authorid);
        ApiHttpClient.post("action/api/comment_reply", params, handler);
    }


    public static void deleteComment(int id, int mTabId, int replyid,
            int authorid, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("id", id);
        params.put("mTabId", mTabId);
        params.put("replyid", replyid);
        params.put("authorid", authorid);
        ApiHttpClient.post("action/api/comment_delete", params, handler);
    }

    public static void getSearchList(String mTabId, String content,
            int pageIndex, AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        params.put("mTabId", mTabId);
        params.put("content", content);
        params.put("pageIndex", pageIndex);
        params.put("pageSize", AppContext.PAGE_SIZE);
        ApiHttpClient.post("action/api/search_list", params, handler);
    }

    public static void updateMyPortrait(String uid, File portrait, AsyncHttpResponseHandler handler) throws FileNotFoundException {
        RequestParams params = new RequestParams();
        params.put("userId", uid);
        params.put("file", portrait);
        ApiHttpClient.post("portal/userCenter/changeAvatar", params, handler);
    }
    /**
     * 摇一摇，随机数据
     * 
     * @param handler
     */
    public static void shake(AsyncHttpResponseHandler handler) {
        shake(-1, handler);
    }

    /**
     * 摇一摇指定请求类型
     */
    public static void shake(int type, AsyncHttpResponseHandler handler) {
        String inter = "action/api/rock_rock";
        if (type > 0) {
            inter = (inter + "/?type=" + type);
        }
        ApiHttpClient.post(inter, handler);
    }

    /***
     * 客户端扫描二维码登陆
     * 
     * @author 火蚁 2015-3-13 上午11:45:47
     * 
     * @return void
     * @param url
     * @param handler
     */
    public static void scanQrCodeLogin(String url,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        String uuid = url.substring(url.lastIndexOf("=") + 1);
        params.put("uuid", uuid);
        ApiHttpClient.getDirect(url, handler);
    }

    /**
     * 获取视频明细
     *
     * @param handler
     */
    public static void getVideoDetail(String id, AsyncHttpResponseHandler handler, AsyncHttpResponseHandler normalHandler) {
        ApiHttpClient.post("mobile/main/v/sec/" + id, null, handler);

        addClick(id, "com.magicode.cms.entiy.base.Video",normalHandler );
//        addPlayCount(id);
    }
    /**
     * 获取视频列表
     * 
     * @param mTabId
     *            tabId
     * @param page
     *            第几页
     * @param handler
     */
    public static void getVideoList(String mTabId, int page,
            AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        if(mTabId != null && !mTabId.equals("-1")){
        	params.put("typeId", mTabId);
        }
        params.put("currentPage", page);
        params.put("pageSize", AppContext.PAGE_SIZE);
//        if (mTabId == NewsList.mTabId_WEEK) {
//            params.put("show", "week");
//        } else if (mTabId == NewsList.mTabId_MONTH) {
//            params.put("show", "month");
//        }
        ApiHttpClient.post("mobile/main/v/datalist", params, handler);
    }

    /**
     * 获取V视明细
     *
     * @param handler
     */
    public static void getVisionDetail(String id, AsyncHttpResponseHandler handler, AsyncHttpResponseHandler normalHandler) {
        ApiHttpClient.post("mobile/main/vs/sec/" + id, null, handler);

        addClick(id, "com.magicode.cms.entiy.base.Video",normalHandler );
//        addPlayCount(id);
    }
    /**
     * 获取V视列表
     *
     * @param mTabId
     *            tabId
     * @param page
     *            第几页
     * @param handler
     */
    public static void getVisionList(String mTabId, int page,
                                    AsyncHttpResponseHandler handler) {
        RequestParams params = new RequestParams();
        if(mTabId != null && !mTabId.equals("-1")){
            params.put("typeId", mTabId);
        }
        params.put("currentPage", page);
        params.put("pageSize", AppContext.PAGE_SIZE);
//        if (mTabId == NewsList.mTabId_WEEK) {
//            params.put("show", "week");
//        } else if (mTabId == NewsList.mTabId_MONTH) {
//            params.put("show", "month");
//        }
        ApiHttpClient.post("mobile/main/vs/datalist", params, handler);
    }
    /**
     * 获取视频频道列表
     * @param handler
     */
    public static void getVideoChannelList( AsyncHttpResponseHandler handler ) {
        RequestParams params = new RequestParams();
        ApiHttpClient.post("mobile/main/v/channel", params, handler);
    }

    /**
     * 获取首页数据列表
     * 第一页获取数据格式为HomePage
     * 第二页获取数据格式为:VideoList
     * @param mCurrentPage
     * @param mHandler
     */
    public static void getHomePage(int mCurrentPage, AsyncHttpResponseHandler mHandler) {
        if(mCurrentPage == 0 || mCurrentPage == 1) {
            RequestParams params = new RequestParams();
//            params.add("pageSize","1");
            ApiHttpClient.post("mobile/p", params, mHandler);
        }
        else{
            RequestParams params = new RequestParams();
//            params.add("pageSize","1");
            params.put("currentPage", mCurrentPage);
            ApiHttpClient.post("mobile/p/json", params, mHandler);
        }
    }
    /**
     增加点击量
     */
    public static void addClick(String id , String entityName, AsyncHttpResponseHandler mHandler){
        String url = "mobile/main/v/creatClick/"+id;
        RequestParams params = new RequestParams();
        params.add("entityName",entityName);
        ApiHttpClient.post(url, params, mHandler);
    }
    /**
     增加播放次数
     */
    public static void addPlayCount(String id  , AsyncHttpResponseHandler mHandler){

        String url = "mobile/main/v/pc/"+id;

        RequestParams params = new RequestParams();
        try {
            ApiHttpClient.post(url, params, mHandler);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    /**
     增加收藏
     */
    public static void addFavorite(String newid , AsyncHttpResponseHandler mHandler){
        String url = "mobile/main/comments/addcl";
        RequestParams params = new RequestParams();
        params.add("newsid",newid);
        params.add("userId",AppContext.getInstance().getLoginUid());
        ApiHttpClient.post(url, params, mHandler);
    }
    /**
     取消收藏
     */
    public static void delFavorite(String newid , AsyncHttpResponseHandler mHandler){
        String url = "mobile/main/comments/delcl";
        RequestParams params = new RequestParams();
        params.add("newsid",newid);
        params.add("userId",AppContext.getInstance().getLoginUid());
        ApiHttpClient.post(url, params, mHandler);
    }
    /**
     检查收藏
     */
    public static void checkFavorite(String newid , AsyncHttpResponseHandler mHandler){
        String url = "mobile/main/comments/checkNewscl";
        RequestParams params = new RequestParams();
        params.add("newsid",newid);
        params.add("userId",AppContext.getInstance().getLoginUid());
        ApiHttpClient.post(url, params, mHandler);
    }
    /**
     * 跳转到权限设置界面
     */
    public static void getAppDetailSettingIntent(Activity context){

        // vivo 点击设置图标>加速白名单>我的app
        //      点击软件管理>软件管理权限>软件>我的app>信任该软件
        Intent appIntent = context.getPackageManager().getLaunchIntentForPackage("com.iqoo.secure");
        if(appIntent != null){
            context.startActivity(appIntent);
//            floatingView = new SettingFloatingView(this, "SETTING", context.getApplication(), 0);
//            floatingView.createFloatingView();
            return;
        }

        // oppo 点击设置图标>应用权限管理>按应用程序管理>我的app>我信任该应用
        //      点击权限隐私>自启动管理>我的app
        appIntent = context.getPackageManager().getLaunchIntentForPackage("com.oppo.safe");
        if(appIntent != null){
            context.startActivity(appIntent);
//            floatingView = new SettingFloatingView(this, "SETTING", context.getApplication(), 1);
//            floatingView.createFloatingView();
            return;
        }

        Intent intent = new Intent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if(Build.VERSION.SDK_INT >= 9){
            intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.setData(Uri.fromParts("package", context.getPackageName(), null));
        } else if(Build.VERSION.SDK_INT <= 8){
            intent.setAction(Intent.ACTION_VIEW);
            intent.setClassName("com.android.settings","com.android.settings.InstalledAppDetails");
            intent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName());
        }
        context.startActivity(intent);
    }
    private final static AsyncHttpResponseHandler mDefaultLoginHandler = new AsyncHttpResponseHandler() {

        @Override
        public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
            try {
                AsyncHttpClient client = ApiHttpClient.getHttpClient();
                HttpContext httpContext = client.getHttpContext();
                CookieStore cookies = (CookieStore) httpContext
                        .getAttribute(ClientContext.COOKIE_STORE);
                if (cookies != null) {
                    String tmpcookies = "";
                    for (Cookie c : cookies.getCookies()) {
//                        TLog.log(TAG,
//                                "cookie:" + c.getName() + " " + c.getValue());
                        tmpcookies += (c.getName() + "=" + c.getValue()) + ";";
                    }
//                    TLog.log(TAG, "cookies:" + tmpcookies);
                    AppContext.getInstance().setProperty(AppConfig.CONF_COOKIE,
                            tmpcookies);
                    ApiHttpClient.setCookie(ApiHttpClient.getCookie(AppContext
                            .getInstance()));
                    HttpConfig.sCookie = tmpcookies;
                }
                ObjectMapper mapper = new ObjectMapper();
                User user = mapper.readValue(arg2, User.class);

                if (user.isOk()) {
                    // 保存登录信息
                    AppContext.getInstance().saveUserInfo(user);
//                    hideWaitDialog();
//                    handleLoginSuccess();
                } else {
                    AppContext.getInstance().cleanLoginInfo();
//                    hideWaitDialog();
//                    AppContext.showToast(user.getMessage());
                }
            } catch (Exception e) {
                e.printStackTrace();
                onFailure(arg0, arg1, arg2, e);
            }
        }

        @Override
        public void onFailure(int arg0, Header[] arg1, byte[] arg2,
                              Throwable arg3) {
//            hideWaitDialog();
//            AppContext.showToast(R.string.tip_login_error_for_network);
        }
    };
}
